package com.example.lx6_1

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.base.mvvm.BaseActivity
import com.example.lx6_1.adapter.AreaAdapter
import com.example.lx6_1.area.AreaViewModel
import com.example.lx6_1.databinding.ActivityMainBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
@Route(path = "/app/MainActivity")
class MainActivity : BaseActivity<ActivityMainBinding,AreaViewModel>() {

    val areaAdapter by lazy { AreaAdapter() }
    override fun initView() {
        binding.rvPark.apply {
            adapter = areaAdapter
            layoutManager = LinearLayoutManager(this@MainActivity)
        }
        lifecycleScope.launch {
            viewModel.getArea().collect{
                areaAdapter.submitData(it)
            }
        }

        binding.textView.setOnClickListener {
            ARouter.getInstance().build("/app/MainActivity2").navigation()
        }
    }

    override fun initData() {

    }
}